package com.snail.auth.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.util.Set;

/**
 * @author HOU
 * @descripton UserDetails实现类，避免系统User类过多不必要字段加载
 * @date 2021/5/27
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class SecurityUser implements UserDetails {
    private Long userId;
    private String name;
    private String username;
    private String password;
    private Integer status;
    private String auths;
    private Set<? extends GrantedAuthority> authorities;

    public SecurityUser(Long userId, String name, String username, String password, Set<? extends GrantedAuthority> authorities) {
        this.userId = userId;
        this.name = name;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }
}
